<template>
	<view>
		<view class="top">
			<image src="@/static/admin/detailBg.png" mode="widthFix"></image>
			<view class="info">
				<image :src="info.avatar" mode=""></image>
				<view class="name">
					{{info.nickname}}
				</view>
				<text class="post">{{info.post_name}}</text>
			</view>
		</view>
		<view class="wrap">
			<view class="list">
				<view class="col">
					<view class="left">
						<image src="@/static/admin/icon/info-icon4.png" mode=""></image> 身份证号
					</view>
					<view class="right">
						{{info.id_number}}
					</view>
				</view>
				<view class="col">
					<view class="left">
						<image src="@/static/admin/icon/info-icon5.png" mode=""></image> 手机号
					</view>
					<view class="right">
						{{info.mobile}}
					</view>
				</view>
				<view class="col">
					<view class="left">
						<image src="@/static/admin/icon/info-icon6.png" mode=""></image> 岗位
					</view>
					<view class="right">
						{{info.post_name}}
					</view>
				</view>
				<view class="col">
					<view class="left">
						<image src="@/static/admin/icon/info-icon7.png" mode=""></image> 家庭住址
					</view>
					<view class="right">
						{{info.address}}
					</view>
				</view>
			</view>
			<view class="row">
				<view class="col" @click="goUrl('add')">
					<image src="@/static/admin/index-icon5.png" mode=""></image>
					<view class="right">
						加分
					</view>
				</view>
				<view class="col" @click="goUrl('minus')">
					<image src="@/static/admin/index-icon6.png" mode="">
					</image>
					<view class="right">
						减分
					</view>
				</view>
			</view>
			<view class="submitBtn" @click="goEdit">
				编辑资料
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {
					nickname: '',
					post_name: ''
				},
				work_no: ''
			}
		},
		onLoad(option) {
			this.work_no = option.work_no
		},
		onShow() {
			this.getInfo()
		},
		methods: {
			getInfo() {
				this.$post("/worker/worker", {
					work_no: this.work_no
				}).then(res => {
					this.info = res.data
				})
			},
			goEdit() {
				uni.navigateTo({
					url: "/pages/admin/index/add/add?work_no=" + this.work_no
				})
			},
			goUrl(type) {
				uni.navigateTo({
					url: `/pages/admin/index/bonus/detail?work_no=${this.work_no}&name=${this.info.nickname}&length=1&type=${type}`
				})
			}
		},
	}
</script>

<style lang="scss">
	.top {
		position: relative;
		height: 400rpx;

		.bg {
			width: 100%;
			height: 400rpx;
		}

		.info {
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			color: #fff;
			text-align: center;

			image {
				width: 128rpx;
				height: 128rpx;
				border-radius: 50%;
				border: 6rpx solid #fff;

			}

			.name {
				font-size: 34rpx;
				margin: 20rpx 0;
			}

			.post {
				background-color: #1752D9;
				font-size: 22rpx;
				padding: 6rpx 20rpx;
				border-radius: 50px;
			}
		}
	}

	.list {

		.col {
			display: flex;
			align-items: center;
			font-size: 30rpx;
			justify-content: space-between;
			align-items: center;
			padding: 40rpx 0;
			border-bottom: 1rpx solid #eee;
		}

		.left {
			display: flex;
			align-items: center;

			image {
				width: 38rpx;
				height: 38rpx;
				margin-right: 16rpx;
			}
		}

		.right {
			color: #808080
		}

	}

	.row {
		display: flex;
		align-items: center;
		padding-top: 30rpx;

		.col {
			width: 50%;
			text-align: center;
			display: flex;
			align-items: center;
			justify-content: center;

			image {
				width: 60rpx;
				height: 60rpx;
				margin-right: 16rpx;
			}
		}
	}

	.submitBtn {
		margin-top: 90rpx;
	}
</style>